/*
 * $Id: Geometry.java 52 2010-01-11 01:42:30Z aaron.day $
 */
package org.crazydays.gameplan.map;


import java.io.Serializable;

/**
 * Geometry represents the geometry for a map.
 */
public class Geometry
    implements Serializable
{
    /** serial version uid */
    public final static long serialVersionUID =
        "$Id: Geometry.java 52 2010-01-11 01:42:30Z aaron.day $".hashCode();

    /** height */
    protected int height;

    /** width */
    protected int width;

    /** geometry type */
    protected GridType type;

    /** size */
    protected int size;

    /**
     * Geometry constructor.
     */
    public Geometry()
    {
    }

    /**
     * Geometry constructor.
     * 
     * @param height Height
     * @param width Width
     * @param type Type
     * @param size Size
     */
    public Geometry(int height, int width, GridType type, int size)
    {
        setHeight(height);
        setWidth(width);
        setType(type);
        setSize(size);
    }

    /**
     * Set height.
     * 
     * @param height Height
     */
    public void setHeight(int height)
    {
        this.height = height;
    }

    /**
     * Get height.
     * 
     * @return Height
     */
    public int getHeight()
    {
        return height;
    }

    /**
     * Set width.
     * 
     * @param width Width
     */
    public void setWidth(int width)
    {
        this.width = width;
    }

    /**
     * Get width.
     * 
     * @return Width
     */
    public int getWidth()
    {
        return width;
    }

    /**
     * Set size.
     * 
     * @param size Size
     */
    public void setSize(int size)
    {
        this.size = size;
    }

    /**
     * Get size.
     * 
     * @return Size
     */
    public int getSize()
    {
        return size;
    }

    /**
     * Get type.
     * 
     * @param type Type
     */
    public void setType(GridType type)
    {
        this.type = type;
    }

    /**
     * Get type.
     * 
     * @return Type
     */
    public GridType getType()
    {
        return type;
    }

    /**
     * HashCode.
     * 
     * @return HashCode
     * @see java.lang.Object#hashCode()
     */
    public int hashCode()
    {
        return getHeight() + getWidth() + getSize() + getType().hashCode();
    }

    /**
     * Equals.
     * 
     * @param object Object
     * @return Equals
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object object)
    {
        if (object == null) {
            return false;
        }

        if (!(object instanceof Geometry)) {
            return false;
        }

        Geometry geometry = (Geometry) object;

        if (getHeight() != geometry.getHeight()) {
            return false;
        }

        if (getWidth() != geometry.getWidth()) {
            return false;
        }

        if (getType() != geometry.getType()) {
            return false;
        }

        if (getSize() != geometry.getSize()) {
            return false;
        }

        return true;
    }

    /**
     * To string.
     * 
     * @return String
     * @see java.lang.Object#toString()
     */
    public String toString()
    {
        StringBuffer buffer = new StringBuffer();

        buffer.append("size: ").append(getSize());
        buffer.append(" type: ").append(getType());

        return buffer.toString();
    }
}
